/**
 *
 * The MIT License
 *
 * Copyright (c) 2009 Noritaka Horio All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 * 
 * @author Noritaka Horio 
 * @copyright Copyright (c) 2009 Noritaka Horio All rights reserved.
 * @license The MIT License
 * @version $Rev: 185 $ $Date: 2009-11-07 12:22:46 +0000 (Sat, 07 Nov 2009) $
 * @see http://mootools.net
 * 
 */

var WindowFactory = {

	createWindow: function(options,size) {
		var op = new air.NativeWindowInitOptions();
		var properies = options;
		for (var name in properies) {
			op[name] = properies[name];
		}

		var win = new air.NativeWindow(op);
		win.stage.align = "TL"; 
		win.stage.scaleMode = "noScale"; 

		win.height = size.height;
		win.width = size.width;

		return win;
	}

}

var WindowOptions = {
	"information": {
		"systemChrome": air.NativeWindowSystemChrome.STANDARD,
		"type": air.NativeWindowType.NORMAL,
		"transparent": false,
		"maximizable": false,
		"minimizable": false,
		"resizable": false
	},
	"configuration": {
		"systemChrome": air.NativeWindowSystemChrome.STANDARD,
		"type": air.NativeWindowType.NORMAL,
		"transparent": false,
		"maximizable": false,
		"minimizable": false,
		"resizable": false
	},

	"timepicker": {
		"systemChrome": air.NativeWindowSystemChrome.NONE,
		"type": air.NativeWindowType.NORMAL,
		"transparent": true,
		"maximizable": false,
		"minimizable": false,
		"resizable": false
	},

	"pluginpicker": {
		"systemChrome": air.NativeWindowSystemChrome.NONE,
		"type": air.NativeWindowType.NORMAL,
		"transparent": true,
		"maximizable": false,
		"minimizable": false,
		"resizable": false
	},

	"minutespicker": {
		"systemChrome": air.NativeWindowSystemChrome.NONE,
		"type": air.NativeWindowType.NORMAL,
		"transparent": true,
		"maximizable": false,
		"minimizable": false,
		"resizable": false
	},

	"notify": {
		"systemChrome": air.NativeWindowSystemChrome.NONE,
		"type": air.NativeWindowType.LIGHTWEIGHT,
		"transparent": true,
		"maximizable": false,
		"minimizable": false,
		"resizable": false
	}

};

var WindowSize = {
	"information": {"height": 400, "width": 300},
	"configuration": {"height": 500, "width": 540},
	"timepicker": {"height": 320, "width": 267},
	"pluginpicker": {"height": 300, "width": 322},
	"minutespicker": {"height": 300, "width": 322},
	"notify": {"height": 100, "width": 300}
};



var WindowMediator = {

	closeWindow: function(name) {
		this.windows.erase(name);
	},

	closeNotifyWindow:function(prarameters) {
		try {
			var loader = this.loader;
			var widnowDoc = loader.window.document;
			var contentBody = widnowDoc.body;
			var title = $(contentBody).getElement("h1.title");
			var content = $(contentBody).getElement("p.content");
			title.set("html", prarameters.title);
			content.set("html", prarameters.content);
		} catch (e) {
			air.trace(e.message);
		}
	}
};

